/*
 */
package org.hook.showcase.base.clone;

/**
 * @author suwuqiang 2011-12-28
 */
public class NormalCloneCase {

	public void changeObject(NormalCloneObject o) {
		o.name = "name is vivian.";
	}

	public void changeInt(int i) {
		i = i + 1;
	}

	public static void main(String[] args) {
		NormalCloneCase test = new NormalCloneCase();
		NormalCloneObject o1 = new NormalCloneObject();
		NormalCloneObject o2 = new NormalCloneObject();
		System.out.println("o1:" + o1);
		System.out.println("o2:" + o2);
		System.out.println("--------------------");
		o2 = o1.clone();
		o2.name = "name is sabinna.";
		System.out.println("o2.name:" + o2.name);
		int i = 10;
		System.out.println("before change:" + o1.name);
		System.out.println("before change:" + i);
		test.changeObject(o1);
		test.changeInt(i);
		System.out.println("after change:" + o1.name);
		System.out.println("after change:" + i);
		System.out.println("o1:" + o1);
		System.out.println("o2:" + o2);
	}
}

class NormalCloneObject implements Cloneable {
	String name = "name is alex.";

	@Override
	protected NormalCloneObject clone() {
		NormalCloneObject o = null;
		try {
			o = (NormalCloneObject) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return o;
	}
}